﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.NetworkInformation;

namespace NetTraceLib
{
    [Serializable()]
    public class RouteDiscoveryException:   Exception 
    {
        public enum RouteDiscoveryError
        {
           NoDestinationAddress,
           DestinationTooFar,
           ErrorProbingHop
        }

        public RouteDiscoveryError Error { get; protected set; }
        public IPStatus IPStatus { get; protected set; }
        public int Hop { get; protected set; }


        public override string Message
        {
            get
            {
                switch(Error)
                {
                    case RouteDiscoveryError.NoDestinationAddress:
                        return "Destination address does not have a valid address to ping.";
                    case RouteDiscoveryError.DestinationTooFar:
                        return "Destination too far.";
                    case RouteDiscoveryError.ErrorProbingHop:
                        return "Error probing hop.";
                    default:
                        return "Could not discover route.";
                }
            }
        }

        public RouteDiscoveryException(RouteDiscoveryError error)
        {
            this.Error = error;
            this.IPStatus = IPStatus.Unknown;
            this.Hop = 0;
        }

        public RouteDiscoveryException(RouteDiscoveryError error,int hop,IPStatus ipStatus)
        {
            this.Error = error;
            this.IPStatus = ipStatus;
            this.Hop = hop;
        }
    }
}
